package com.ruoyi.warehousemanager.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.warehousemanager.domain.Warehouse;
import com.ruoyi.warehousemanager.mapper.WarehouseMapper;
import com.ruoyi.warehousemanager.pojo.WarehouseVO;
import com.ruoyi.warehousemanager.service.IWarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse> implements IWarehouseService {
    @Autowired
    private WarehouseMapper warehouseMapper;

    /**
     * 查询仓库管理
     *
     * @param warehouseId 仓库管理主键
     * @return 仓库管理
     */
    @Override
    public Warehouse selectWarehouseByWarehouseId(Long warehouseId)
    {
        return warehouseMapper.selectWarehouseByWarehouseId(warehouseId);
    }

    /**
     * 查询仓库管理列表
     *
     * @param warehouse 仓库管理
     * @return 仓库管理
     */
    @Override
    public List<WarehouseVO> selectWarehouseList(WarehouseVO warehouse)
    {
        return warehouseMapper.selectWarehouseList(warehouse);
    }

    /**
     * 新增仓库管理
     *
     * @param warehouse 仓库管理
     * @return 结果
     */
    @Override
    public int insertWarehouse(Warehouse warehouse)
    {
        int warehouseself=warehouseMapper.insertWarehouse(warehouse);
        int todept=warehouseMapper.insertWarehousetoDept(warehouse);
        return warehouseself+todept;
    }

    /**
     * 修改仓库管理
     *
     * @param warehouse 仓库管理
     * @return 结果
     */
    @Override
    public int updateWarehouse(Warehouse warehouse)
    {
        int warehouseself=warehouseMapper.updateWarehouse(warehouse);
        int todept=warehouseMapper.updateWarehouseinDept(warehouse);
        return warehouseself+todept;
    }

    /**
     * 批量删除仓库管理
     *
     * @param warehouseIds 需要删除的仓库管理主键
     * @return 结果
     */
    @Override
    public int deleteWarehouseByWarehouseIds(Long[] warehouseIds)
    {
        int warehouseself=warehouseMapper.deleteWarehouseByWarehouseIds(warehouseIds);
        int todept=warehouseMapper.deleteDeptByWarehouseIds(warehouseIds);
        return warehouseself+todept;
    }

    /**
     * 删除仓库管理信息
     *
     * @param warehouseId 仓库管理主键
     * @return 结果
     */
    @Override
    public int deleteWarehouseByWarehouseId(Long warehouseId)
    {
        int warehouseself=warehouseMapper.deleteWarehouseByWarehouseId(warehouseId);
        int todept=warehouseMapper.deleteDeptByWarehouseId(warehouseId);
        return warehouseself+todept;
    }
}
